# Figure 1

library(tidyverse)

DATA     <- read.csv(file.choose(), header=TRUE) 

DATA$PID <- factor(DATA$PID, levels=DATA$PID)

theme.z  <- theme(
        axis.text.x        = element_text(size=15 , color="black", hjust=1, vjust=0.5, angle=90, margin=margin(t=10,b=10)),
        axis.text.x.top    = element_blank(),
        axis.text.y        = element_text(size=15 , color="black", margin=margin(r=7)),
        axis.text.y.right  = element_blank(),
        axis.ticks.length  = unit(10,"pt"),
        axis.title.x       = element_blank(),
        axis.title.y       = element_text(size=15 , color="black", margin=margin(r=14,l=0)),
        legend.position	   = "none",
        panel.background   = element_rect(size=0.5, color="black", fill="white", linetype="solid"),
        panel.border       = element_rect(size=1.5, color="black", fill=NA     , linetype="solid"),
        panel.grid.major.x = element_line(color="gray"),
        panel.grid.major.y = element_line(color="gray"),
        panel.grid.minor.x = element_blank(), 
        panel.grid.minor.y = element_blank(),
        plot.background    = element_rect(fill="white"),
        plot.caption       = element_text(size=12 , hjust=0  , margin=margin(t=10)),
        plot.margin        = unit(c(t=25,r=5,b=5,l=5),"pt"),
        plot.subtitle      = element_text(size=15 , hjust=0.5,              margin=margin(b=7)),
        plot.title         = element_text(size=20 , hjust=0.5, face="bold", margin=margin(t=0,b=10)),
        strip.background   = element_rect(color="black", fill="black"),
        strip.text.x       = element_text(size=18 , color="white", face="bold"))

ggplot(data=DATA, aes(x=PID, y=PE)) +
  geom_errorbar(aes(ymin=CILO, ymax=CIHI), size=0.75, width=0.2) + 
  geom_point(size=3.5) +
  scale_x_discrete(name="Partisanship (Strong Democrat to Strong Republican)") +
  scale_y_continuous(name="Importance of the issue\nto the respondent personally", expand=c(0,0), limits=c(3.5,4), breaks=seq(3.5,4,0.1), labels=sprintf("%0.3f", round(seq(3.5,4,0.1), digits=2))) +
  theme.z

ggsave(file="Figure 1.wmf", width=5, height=6)
getwd()